package com.neu.niuyuchao.servlet;

import com.neu.niuyuchao.service.MgrInfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "DorCompareServlet", urlPatterns = {"/DorCompareServlet.do"})
public class DorCompareServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String pageIndex=request.getParameter("pageIndex");
        MgrInfoService mgrService=new MgrInfoService();
        String pageNum=mgrService.getPageNum(10);
//        System.out.println(pageNum);
        List<Map<String,Object>> list=mgrService.doDorCompare(pageIndex,10);
        HttpSession session=request.getSession();
        session.setAttribute("pageIndex",pageIndex);
        session.setAttribute("pageNum",pageNum);
        session.setAttribute("list",list);
        request.getRequestDispatcher("WEB-INF/Mgr/dorcompare.jsp").forward(request,response);
        }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
